<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main"/>
        <title>Edit Component</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton" style="float:right">
                <a class="edit" href="${createLinkTo(dir:'admin')}">Admin</a>
            </span>
            <span class="menuButton">
                <a class="home" href="${createLinkTo(dir:'')}">Home</a>
            </span>
            <span class="menuButton">
                <g:link class="list" action="list">Component List</g:link>
            </span>
            <span class="menuButton">
                <g:link class="create" action="create">New Component</g:link>
            </span>
        </div>
        <div class="body">
            <h1>Edit Component</h1>
            <g:if test="${flash.message}">
                <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${component}">
                <div class="errors">
                    <g:renderErrors bean="${component}" as="list"/>
                </div>
            </g:hasErrors>
            <g:form method="post">
                <input type="hidden" name="id" value="${component?.id}"/>
                <div class="dialog">
                    <table>
                        <tbody>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="name">Name:</label>
                                </td>
                                <td valign="top"
                                    class="value ${hasErrors(bean:component,field:'name','errors')}">
                                    <input type="text" id="name" name="name"
                                        value="${fieldValue(bean:component,field:'name')}"/>
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="project">Project:</label>
                                </td>
                                <td valign="top"
                                    class="value ${hasErrors(bean:component,field:'project','errors')}">
                                    <g:select optionKey="id" from="${Project.list()}"
                                        name="project.id" value="${component?.project?.id}"/>
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="issues">Issues:</label>
                                </td>
                                <td valign="top"
                                    class="value ${hasErrors(bean:component,field:'issues','errors')}">
                                    <ul>
                                        <g:each var="i" in="${component?.issues?}">
                                            <li>
                                                <g:link controller="issue" action="show"
                                                  id="${i.id}">${i}</g:link>
                                            </li>
                                        </g:each>
                                    </ul>
                                    <g:link controller="issue"
                                        params="['component.id':component?.id]" action="create">Add
                                        Issue</g:link>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button">
                        <g:actionSubmit class="save" value="Update"/>
                    </span>
                    <span class="button">
                        <g:actionSubmit class="delete" onclick="return confirm('Are you sure?');"
                            value="Delete"/>
                    </span>
                </div>
            </g:form>
        </div>
    </body>
</html>
